﻿using AnQinFrameWorkAPI.Entity.Blog.DTO.BlogTeamMember;
using AnQinFrameWorkAPI.Entity.Blog.View.BlogTeamMember;
using AnQinFrameWorkAPI.Service.Blog;
using FrameWork.Entity;
using Microsoft.AspNetCore.Mvc;

namespace AnQinFrameWorkAPI.Controllers.Blog;

/// <summary>
///     团队成员API
/// </summary>
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = "Blog")]
public class BlogTeamMemberController : ControllerBase
{
    // 业务服务接口
    private readonly BlogTeamMemberService _blogTeamMemberService;

    // 构造注入
    public BlogTeamMemberController(BlogTeamMemberService blogTeamMemberService)
    {
        _blogTeamMemberService = blogTeamMemberService;
    }

    /// <summary>
    ///     获取团队成员列表（分页）
    /// </summary>
    /// <param name="searchDTO">查询条件</param>
    [ProducesResponseType(typeof(BlogTeamMemberView), 200)]
    [HttpGet]
    public async Task<IActionResult> GetBlogTeamMemberList([FromQuery] BlogTeamMemberSearchDTO searchDTO)
    {
        var response = await _blogTeamMemberService.GetBlogTeamMemberList(searchDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     新增团队成员
    /// </summary>
    /// <param name="addDTO">成员数据</param>
    [HttpPost]
    public async Task<IActionResult> AddBlogTeamMember([FromBody] BlogTeamMemberAddDTO addDTO)
    {
        var response = await _blogTeamMemberService.AddBlogTeamMember(addDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     更新团队成员
    /// </summary>
    /// <param name="updateDTO">成员数据</param>
    [HttpPut]
    public async Task<IActionResult> PutBlogTeamMember([FromBody] BlogTeamMemberUpdateDTO updateDTO)
    {
        var response = await _blogTeamMemberService.PutBlogTeamMember(updateDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     删除团队成员
    /// </summary>
    /// <param name="deleteDTO">删除参数</param>
    [HttpDelete]
    public async Task<IActionResult> DeleteBlogTeamMember([FromBody] SingleIdDTO deleteDTO)
    {
        var response = await _blogTeamMemberService.DeleteBlogTeamMember(deleteDTO);
        return StatusCode(response.Status, response);
    }
}